package cn.yangliu.config.custom;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

/**
 * @author 杨柳
 * @date 2019-05-22
 */
@Component
public class LogoutSuccessHandler implements org.springframework.security.web.authentication.logout.LogoutSuccessHandler, SecurityHandler {

    /**
     * 退出登录成功,以json方式响应
     *
     * @param request        请求
     * @param response       响应
     * @param authentication 登录凭证
     * @throws IOException      io异常
     * @throws ServletException servlet 异常
     */
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
                                Authentication authentication) throws IOException, ServletException {
        handle(request, response, HttpStatus.OK);
    }
}
